<?php
defined( '_JEXEC' ) or die( 'Restricted access' );date_default_timezone_set('America/Mexico_City');setlocale(LC_ALL, 'es_ES.UTF-8');
?>
<form action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="adminForm">
<h1><?php echo JText::_('COM_PQCE_EVCAL');?></h1>
<div id="editcell">
	<table class="adminlist">
	<?php if ($aId=$this->aconte[0]->id) : ?>
	<thead>
		<tr>
			<th width="5">
				<?php echo JHTML::_( 'grid.sort', 'ID', 'id', $this->lists['order_Dir'], $this->lists['order']); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->aconte ); ?>);" />
			</th>			
			<th width="50"><?php echo JHTML::_( 'grid.sort', JText::_('COM_PQCE_DATE'), 'refdate', $this->lists['order_Dir'], $this->lists['order']); ?>
			</th>
			<th width="15"><?php echo JHTML::_( 'grid.sort', JText::_('COM_PQCE_TYPE'), 'type', $this->lists['order_Dir'], $this->lists['order']); ?>
			</th>
			<th width="50"> <?php echo JText::_('COM_PQCE_HRB');?>
			</th>
			<th width="50"> <?php echo JText::_('COM_PQCE_SHORTDESC');?>
			</th>
		<th width="25"> <?php echo JText::_('COM_PQCE_SMALLIMG');?></th>
		<th width="20"> <?php echo JText::_('COM_PQCE_ACT');?>
			</th>

		</tr>
	</thead>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->aconte ); $i < $n; $i++)	{
		$row = &$this->aconte[$i];
		$checked 	= JHTML::_('grid.id',   $i, $row->id );
		$link 		= JRoute::_( 'index.php?option=com_pqce&task=editFact&cid[]='. $row->id );
		$linkA 		= JRoute::_( 'index.php?option=com_pqce&task=toggleActiveFact&active='. (int)(1-$row->active). '&cid[]='. $row->id );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $row->id; ?>
			</td>
			<td>
				<?php echo $checked; ?>
			</td>
			<td>
				<a href="<?php echo $link; ?>"><?php $f=$row->refdate; $f=explode('-',$f);$y=(int)$f[0];$m=(int)$f[1];$d=(int)$f[2]; $tp=$row->type;$buff=JText::_("COM_PQCE_MONTH$m");unset($f);$h=explode('-',$row->enddate);$buff1=JText::_("COM_PQCE_MONTH".(int)$h[1]);
					switch ($tp){ case 0:
						$fecha=JText::sprintf('COM_PQCE_FULLDATE',$d,$buff,$y);break;
						case 1:
						$fecha=JText::sprintf('COM_PQCE_ANNDATE',$d,$buff);$fecha.= ($h[2]!='0000')? JText::sprintf('COM_PQCE_FULLDATE1',(int)$h[2],$buff1,(int)$h[0]):'';break;
						case 2:
						$fecha=JText::sprintf('COM_PQCE_MONTHDATE',$d);$fecha.= ($h[2]!='0000')? JText::sprintf('COM_PQCE_FULLDATE1',(int)$h[2],$buff1,(int)$h[0]):'';break;
						case 3:
						$fecha=JText::sprintf('COM_PQCE_DAYDATE',$d,$buff,$y); $fecha.= ($h[2]!='0000')? JText::sprintf('COM_PQCE_FULLDATE1',(int)$h[2],$buff1,(int)$h[0]):'';break;
						case 4:
						$fecha=JText::sprintf('COM_PQCE_WEEKDATE',$d,$buff,$y); $fecha.= ($h[2]!='0000')? JText::sprintf('COM_PQCE_FULLDATE1',(int)$h[2],$buff1,(int)$h[0]):'';break;}
					unset($h);
					echo $fecha; ?></a>
			</td>
			<td><?php
			switch ($tp) {case 0:$tl=JText::_('COM_PQCE_OO');break;case 1:$tl=JText::_('COM_PQCE_ANNUAL');break;case 2:$tl=JText::_('COM_PQCE_MONTHLY');break;case 3:$tl=JText::_('COM_PQCE_DAILY');break;case 4:$tl=JText::_('COM_PQCE_WEEKLY');break;}
			echo $tl;
			?>
			</td>
			<td><a href="<?php echo $link; ?>"><?php echo sprintf('%02s',$row->hr).':'.sprintf('%02s',$row->min); ?></a>
			</td>
			<td>
				<a href="<?php echo $link; ?>"><?php echo $row->short_desc; ?></a>
			</td>
			<td>
				<img src="<?php echo JURI::root().$row->short_desc_image; ?>" width="25" height="25"/>
			</td>
			<td>
				<a href="<?php echo $linkA.'&'.JUtility::getToken().'=1';?>"><?php echo ($row->active==1)? JText::_('COM_PQCE_YES'): JText::_('COM_PQCE_NO');?></a>
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	<?php else : ?>
		<thead>
		<tr class='0'>
			<th><span><?php echo JText::_('COM_PQCE_NOEVENTFOUND');?><span></th>
		</tr>
		</thead>
	<?php endif;?>
	</table>
</div>
<input type="hidden" name="option" value="com_pqce" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
